import {createRouter, createWebHistory} from 'vue-router';

import AddUserAddress from '../views/AddUserAddress.vue';
import Administrator from '../views/Administrator.vue';
import BusinessCreate from '../views/BusinessCreate.vue';
import BusinessInfo from '../views/BusinessInfo.vue';
import BusinessList from '../views/BusinessList.vue';
import BusinessManage from '../views/BusinessManage.vue';
import BusinessMine from '../views/BusinessMine.vue';
import BusinessModify from '../views/BusinessModify.vue';
import EditUserAddress from '../views/EditUserAddress.vue';
import Index from '../views/Index.vue';
import Login from '../views/Login.vue';
import MyComments from '../views/MyComments.vue';
import OrderList from '../views/OrderList.vue';
import Orders from '../views/Orders.vue';
import Payment from '../views/Payment.vue';
import Register from '../views/Register.vue';
import TransactionHistory from '../views/TransactionHistory.vue'
import UserAddress from '../views/UserAddress.vue';
import UserProfile from '../views/UserProfile.vue';
import Wallet from '../views/Wallet.vue';

const routes = [
  {path: '/', name: 'Home', component: Index},
  {path: '/index', name: 'Index', component: Index},
  {path: '/businessList', name: 'BusinessList', component: BusinessList},
  {path: '/businessInfo', name: 'BusinessInfo', component: BusinessInfo},
  {path: '/login', name: 'Login', component: Login},
  {path: '/orders', name: 'Orders', component: Orders},
  {path: '/userAddress', name: 'UserAddress', component: UserAddress},
  {path: '/payment', name: 'Payment', component: Payment},
  {path: '/orderList', name: 'OrderList', component: OrderList},
  {path: '/addUserAddress', name: 'AddUserAddress', component: AddUserAddress},
  {
    path: '/editUserAddress',
    name: 'EditUserAddress',
    component: EditUserAddress
  },
  {path: '/register', name: 'Register', component: Register},
  {
    path: '/manage',
    name: 'BusinessManage',
    component: BusinessManage,
    meta: {requiresBusinessAuth: true}
  },
  {path: '/Administrator', name: 'Administrator', component: Administrator},
  {path: '/userProfile', name: 'UserProfile', component: UserProfile},
  {path: '/myComments', name: 'MyComments', component: MyComments},
  {path: '/mine', name: 'BusinessMine', component: BusinessMine},
  {path: '/create', name: 'BusinessCreate', component: BusinessCreate},
  {path: '/modify/:id', name: 'BusinessModify', component: BusinessModify},
  {path: '/wallet', name: 'Wallet', component: Wallet},
  {
    path: '/wallet/transactions',
    name: 'TransactionHistory',
    component: TransactionHistory
  }
];

// 创建路由实例
const router =
    createRouter({history: createWebHistory(process.env.BASE_URL), routes});

// 解决重复路由报异常问题（Vue 3 中不需要手动修改 push 方法）
export default router;